package org.batatasframework.support.searchable.result;

import java.sql.ResultSet;
import java.util.List;

import org.batatasframework.support.database.sql.field.SelectFragment;
import org.batatasframework.support.searchable.SearchableType;


public class SearchResultBuffer extends AbstractResultStream<SearchResultHead, ResultRow>{

	/**
	 * 
	 */
	private static final long serialVersionUID = -8200206957082581884L;

//	public SearchResultBuffer(Executable executable) throws Exception {
//		super(executable);
//	}

	@Override
	protected SearchResultHead buildHead(SelectFragment sf) {
		return new SearchResultHead(sf);
	}

//	@Override
	protected ResultRow newRow(List<SearchResultHead> heads) throws Exception {
		return new SearchResultRow(heads);
	}

	@Override
	protected void internalRead(ResultSet rs) throws Exception {
		while(rs.next()){
			//解析从数据库查询出来的一行记录
			ResultRow row = newRow(heads);
			row.read(rs);
			rows.add(row);
		}
	}
	
	@Override
		public SearchableType getSearchableType() {
			return SearchableType.SEARCH;
		}
}
